package com.aacar.controller.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.aacar.controller.ValidController;
import com.aacar.dto.Header;
import com.aacar.service.TokenService;
import com.aacar.utils.ResultInfoUtil;
import com.aacar.vo.TokenVo;
import com.alibaba.fastjson.JSON;

@RestController
@RequestMapping("/token")
public class TokenController extends ValidController{
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	
	@Autowired
	private TokenService tokenService;
	
	
	/**
	 * 获取token
	 * @param userDto
	 * @return
	 */
	@RequestMapping(value = "/retrieveToken/0", method = RequestMethod.POST)
    @ResponseBody
	public Object retrieveToken(@RequestHeader(value="mobilehead") String mobilehead) {
		logger.info("request:/retrieveToken/0");
		TokenVo tv = this.tokenService.retrieveToken();
		Header header = null;
		if(null != mobilehead) {
			header = JSON.parseObject(mobilehead, Header.class);
		}
		return ResultInfoUtil.setSuccessInfo(tv,header.getService());
	}
	
}
